package core.dal;

import core.dto.IDatabase;
import core.dto.IOperatorDTO;
import exceptions.UserNotFoundException;
import exceptions.WrongPasswordException;

public class OperatorFunctionality implements IFunctionality{
	
	IDatabase currentDB;
	
	public OperatorFunctionality(IDatabase db){
		currentDB = db;
	}

	public IOperatorDTO login(int id, String pass) throws UserNotFoundException, WrongPasswordException{
		if (currentDB.getUser(id).getPassword().equals(pass)){
			return currentDB.getUser(id);
			
			}
		throw new WrongPasswordException(pass);
	}
	
	public void logout(){
		
	}
	
	public void changePassword(int id, String newpass) throws UserNotFoundException{
		IOperatorDTO tempUser = this.currentDB.getUser(id);
		tempUser.setPassword(newpass);
		
	}
	
	public void useApplication() {
		
	}
	
}
